public class Solution {
    public int combinationSum4(int[] nums, int target) {
        int[] a = new int[target + 1];
        for (int i = 0; i <= target; i++) {
            for(int num : nums) {
                if(i - num > 0) {
                    a[i] += a[i - num];
                } else if(i - num == 0) {
                    a[i] += 1;
                }
            }
        }
        return a[target];
    }
}